<%--
  Created by IntelliJ IDEA.
  User: zhaohongai
  Date: 2021/5/17
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/public/header/permissionCommon.jspf" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>设备发放记录</title>
    <c:set var="path" value="${pageContext.request.contextPath}" scope="page"/>
    <style type="text/css">
        .layui-table-tips-main{display:none}
        .layui-table-tips-c{display:none}
        .layui-table-grid-down {display: none;}
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部和左侧导航-->
    <div id="header"></div>
    <%--<!--右侧主体区域-->--%>
    <div class="layui-body" >
        <div class="layui-tab layui-tab-brief" lay-filter="DeviceArrangeList">
            <ul class="layui-tab-title">
                <li class="layui-this">设备发放档案</li>
            </ul>
            <div class="layui-tab-content">
                <%-----------发放护工设备信息展示-----------%>
                <!--
                <div id="HgDeviceArrangeInfoShow" class="layui-tab-item">
                    <%-----------搜索 & 添加 功能-----------%>
                    <div class="SearchLoadDevice" style="font-size: small">
                        <%------------搜索功能---------------%>
                        设备ID：
                        <div class="layui-inline">
                            <input class="layui-input" name="device_hg" id="device_hg" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        <div class="layui-inline">
                            <button class="searchBtn" data-type="reload1" style="margin-left:10px;height:30px;width:85px;background-color: #009688;color: white;border: none;border-radius: 5px">
                                <i class="layui-icon layui-icon-search"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -6px;margin-left: 5px;margin-right: 5px">搜 索</div>
                            </button>
                        </div>
                        <%-------------发放护工设备-------------%>
                        <div class="layui-inline" style="float: right">
                            <button class="layui-btn layui-btn-sm" id="addHgDevice" name="addHgDevice"  style="width: 120px;float: right;border-radius: 5px;margin-left: 5px">
                                <i class="layui-icon layui-icon-add-1"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center">发放护工设备</div>
                            </button>
                        </div>
                    </div>
                    <%----------- 信息表格 显示------------%>
                    <table class="layui-hide" id="hgDeviceArrangeInfoList" lay-filter="deviceHg" ></table>
                </div>
                -->
                <%-----------发放护工设备信息展示-----------%>
                <div id="LrDeviceArrangeInfoShow" class="layui-tab-item layui-show">
                    <%-----------搜索 & 添加 功能-----------%>
                    <div class="SearchLoadDevice" style="font-size: small">
                        <%------------搜索功能---------------%>
                        设备ID：
                        <div class="layui-inline">
                            <input class="layui-input" name="device_lr" id="device_lr" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        <div class="layui-inline">
                            <button class="searchBtn" data-type="reload2" style="margin-left:10px;height:30px;width:85px;background-color: #009688;color: white;border: none;border-radius: 5px">
                                <i class="layui-icon layui-icon-search"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -6px;margin-left: 5px;margin-right: 5px">搜 索</div>
                            </button>
                        </div>
                        <div class="layui-inline" style="float: right">
                            <button class="layui-btn layui-btn-sm" id="addLrDevice" name="addLrDevice" style="width: 120px;float: right;border-radius: 5px;margin-left: 5px">
                                <i class="layui-icon layui-icon-add-1"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center">发放老人设备</div>
                            </button>
                        </div>
                    </div>
                    <%----------- 信息表格 显示------------%>
                    <table class="layui-hide" id="lrDeviceArrangeInfoList" lay-filter="deviceLr" ></table>
                </div>
            </div>
        </div>
    </div>
    <!--底部-->
    <div id="footer"></div>
    <script src="${webPath}/js/permission/auth/permList.js"></script>
    <script>
        $("#header").load("${webPath}/publicPages/permission/fragments/header.jsp");
        $("#footer").load("${webPath}/publicPages/permission/fragments/footer.jsp");
    </script>
    <script type="text/javascript" src="${webPath}/js/Sign/DeviceArrangeList.js"></script>
    <%-------------查看编辑删除框--------------%>
    <%--护工设备页面的编辑框--%>
    <script type="text/html" id="Check_Edit_Del_Hg">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <%--老人设备页面的编辑框--%>
    <script type="text/html" id="Check_Edit_Del_Lr">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script type="text/javascript" src="${webPath}/js/utils.js"></script>

    <%--查看护工设备详细信息--%>
    <div class="hgDeviceDetail" id="hgDeviceDetail" style="display: none">
        <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label" >护工设备ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="device_hg" value={device_hg} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">护工身份证</label>
                    <div class="layui-input-block">
                        <input type="text" name="hg_id_number" value={hg_id_number} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label" >护工姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="hg_name" value={hg_name} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">所属机构</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization" value={organization} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="createTime" readonly="readonly" value={createTime} step="1" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">更新时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="updateTime" readonly="readonly" value={updateTime} step="1" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" name="note" value={note} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
        </form>
    </div>

    <%--查看老人设备详细信息--%>
    <div class="lrDeviceDetail" id="lrDeviceDetail" style="display: none">
        <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label" >老人设备ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="device_lr" value={device_lr} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">老人身份证</label>
                    <div class="layui-input-block">
                        <input type="text" name="lr_id_number" value={lr_id_number} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label" >护工姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="lr_name" value={lr_name} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">所属机构</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization" value={organization} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="createTime" readonly="readonly" value={createTime} step="1" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">更新时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="updateTime" readonly="readonly" value={updateTime} step="1" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" name="note" value={note} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
        </form>
    </div>

    <%--编辑护工设备信息--%>
    <div class="editHgDevice" id="hgDeviceEdit" style="display: none;">
        <form class="layui-form layui-form-pane" id="HgDeviceForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>护工设备ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="device_hg" value={device_hg} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>护工身份证</label>
                    <div class="layui-input-block">
                        <input type="text" name="hg_id_number" value={hg_id_number} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>护工姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="hg_name" value={hg_name} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>所属机构</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization" value={organization} lay-verify="required" class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="createTime" class="layui-input" value={createTime} step="1" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">更新时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="updateTime" class="layui-input" value={updateTime} step="1" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" name="note" value={note} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input type="text" name="id" value={id} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handinHg" lay-filter="handinHg" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handinHg)', function(data){
                console.log("[开始提交~]");
                console.log(data.field);
                $.ajax({
                    url:'/DeviceArrangeHg/updateDeviceArrangeHg',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

    <%--编辑老人设备信息--%>
    <div class="editLrDevice" id="lrDeviceEdit" style="display: none;">
        <form class="layui-form layui-form-pane" id="LrDeviceForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>老人设备ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="device_lr" value={device_lr} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>老人身份证</label>
                    <div class="layui-input-block">
                        <input type="text" name="lr_id_number" value={lr_id_number} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>老人姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="lr_name" value={lr_name} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>所属机构</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization" value={organization} lay-verify="required" class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="createTime" class="layui-input" value={createTime} step="1" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">更新时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="updateTime" class="layui-input" value={updateTime} step="1" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" name="note" value={note} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input type="text" name="id" value={id} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handinLr" lay-filter="handinLr" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handinLr)', function(data){
                console.log("[开始提交~]");
                console.log(data.field);
                $.ajax({
                    url:'/DeviceArrangeLr/updateDeviceArrangeLr',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

    <%--发放护工设备--%>
    <div class="chooseHgDevice" id="chooseHgDeviceWindow" style="display: none">
        <form class="layui-form layui-form-pane" id="addHgDeviceForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">设备ID</label>
                <div class="layui-input-inline">
                    <select name="device_hg" id="choose_hg_device" lay-filter="chooseHg" lay-verify="required" lay-search="">
                        <option value="">请选择设备ID</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">护工姓名</label>
                <div class="layui-input-inline">
                    <select name="hg_name" class="layui-form" id="choose_hg_name" lay-filter="chooseHgName" lay-verify="required" lay-search="">
                        <option value="">请选择护工姓名</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">护工身份证</label>
                <div class="layui-input-inline">
                    <select name="hg_id_number" id="choose_hg_id_number" lay-filter="chooseHgId" lay-verify="required" lay-search="">
                        <option value="">请选择护工身份证</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handinAddHgDevice" lay-filter="handinAddHgDevice" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        $("#addHgDevice").on("click", function(){
            var index = layer.open({
                type: 1,  //可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                title: ['发放护工设备', 'font-size:18px;'],
                area: ['700px',"500px"],
                content: $('#chooseHgDeviceWindow')
            });
        })
    </script>
    <script type="text/javascript">
        layui.use('form', function(){
            var form = layui.form;
            $.ajax({
                url:'/DeviceHg/getHgDevice',
                method:'POST',
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                async: false,
                cache: false,
                dataType:'JSON',
                success:function(data){
                    $.each(data,function(index,item){
                        $('#choose_hg_device').append(new Option(item.device_hg));//往下拉菜单里添加元素
                    })

                    form.render("select");//菜单渲染 把内容加载进去

                },
                error:function (data) {
                    console.log("[查询失败~]",data);
                }
            });

            form.on('select(chooseHg)', function(data){
                console.log(data);
                return false;
            })
        })
    </script>
    <script type="text/javascript">
        layui.use('form', function(){
            var form = layui.form;
            $.ajax({
                url:'/staff/getHgNameByCode',
                method:'POST',
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                async: false,
                cache: false,
                dataType:'JSON',
                success:function(data){
                    $.each(data,function(index,item){
                        $('#choose_hg_name').append(new Option(item.name));//往下拉菜单里添加元素
                    })

                    form.render("select");//菜单渲染 把内容加载进去

                },
                error:function (data) {
                    console.log("[查询失败~]",data);
                }
            });

            form.on('select(chooseHgName)', function(data){
                console.log(data);
                var name = data.value;
                console.log(name);
                getHgIdNumber(name);
                return false;
            })
        })
    </script>
    <script type="text/javascript">
        function getHgIdNumber(name){
            layui.use('form', function(){
                var form = layui.form;
                $.ajax({
                    url:'/staff/getHgIdNumberByName',
                    method:'POST',
                    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                    async: false,
                    cache: false,
                    data: {
                        hg_name: name
                    },
                    dataType:'JSON',
                    success:function(data){
                    $('#choose_hg_id_number').empty();
                    $.each(data,function(index,item){
                        $('#choose_hg_id_number').append(new Option(item.id_number));//往下拉菜单里添加元素
                    })

                    form.render("select");//菜单渲染 把内容加载进去

                    },
                    error:function (data) {
                        console.log("[查询失败~]",data);
                    }
                });

                form.on('select(chooseHgId)', function(data){
                    console.log(data);
                    return false;
                })
            })
        }
    </script>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handinAddHgDevice)', function(data){
                console.log("[开始提交~]");
                console.log("[date:]",data);
                $.ajax({
                    url:'/DeviceArrangeHg/addDeviceArrangeHg',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        console.log("发放完成！");
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

    <%--发放老人设备--%>
    <div class="chooseLrDevice" id="chooseLrDeviceWindow" style="display: none">
        <form class="layui-form layui-form-pane" id="addLrDeviceForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">设备ID</label>
                <div class="layui-input-inline">
                    <select name="device_lr" id="choose_lr_device" lay-filter="chooseLr" lay-verify="required" lay-search="">
                        <option value="">请选择设备ID</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">老人姓名</label>
                <div class="layui-input-inline">
                    <select name="lr_name" id="choose_lr_name" lay-filter="chooseLrName" lay-verify="required" lay-search="">
                        <option value="">请选择老人姓名</option>
                   </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">老人身份证</label>
                <div class="layui-input-inline">
                    <select name="lr_id_number" id="choose_lr_id_number" lay-filter="chooseLrId" lay-verify="required" lay-search="">
                        <option value="">请选择老人身份证</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handinAddLrDevice" lay-filter="handinAddLrDevice" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        $("#addLrDevice").on("click", function(){
            var index = layer.open({
                type: 1,  //可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                title: ['发放老人设备', 'font-size:18px;'],
                area: ['700px',"500px"],
                content: $('#chooseLrDeviceWindow')
            });
        })
    </script>
    <script type="text/javascript">
        layui.use('form', function(){
            var form = layui.form;
            $.ajax({
                url:'/DeviceLr/getLrDevice',
                method:'POST',
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                async: false,
                cache: false,
                dataType:'JSON',
                success:function(data){
                    $.each(data,function(index,item){
                        $('#choose_lr_device').append(new Option(item.device_lr));//往下拉菜单里添加元素
                    })

                    form.render("select");//菜单渲染 把内容加载进去

                },
                error:function (data) {
                    console.log("[查询失败~]",data);
                }
            });

            form.on('select(chooseLr)', function(data){
                console.log(data);
                return false;
            })
        })
    </script>
    <script type="text/javascript">
        layui.use('form', function(){
            var form = layui.form;
            $.ajax({
                url:'/elderInfo/getLrNameByCode',
                method:'POST',
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                async: false,
                cache: false,
                dataType:'JSON',
                success:function(data){
                    $.each(data,function(index,item){
                        $('#choose_lr_name').append(new Option(item.name));//往下拉菜单里添加元素
                    })

                    form.render("select");//菜单渲染 把内容加载进去

                },
                error:function (data) {
                    console.log("[查询失败~]",data);
                }
            });

            form.on('select(chooseLrName)', function(data){
                console.log(data);
                var name = data.value;
                getLrIdNumber(name);
                return false;
            })
        })
    </script>
    <script type="text/javascript">
        function getLrIdNumber(name){
            layui.use('form', function(){
                    var form = layui.form;
                    $.ajax({
                        url:'/elderInfo/getLrIdNumberByName',
                        method:'POST',
                        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                        async: false,
                        cache: false,
                        dataType:'JSON',
                        data: {
                            lr_name :name
                        },
                        success:function(data){
                        $('#choose_lr_id_number').empty();
                            $.each(data,function(index,item){
                                $('#choose_lr_id_number').append(new Option(item.id_number));//往下拉菜单里添加元素
                            })

                            form.render("select");//菜单渲染 把内容加载进去

                        },
                        error:function (data) {
                            console.log("[查询失败~]",data);
                        }
                    });

                    form.on('select(chooseLrId)', function(data){
                        console.log(data);
                        return false;
                    })
            })
        }
    </script>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handinAddLrDevice)', function(data){
                console.log("[开始提交~]");
                console.log("[date:]",data);
                $.ajax({
                    url:'/DeviceArrangeLr/addDeviceArrangeLr',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

</div>
</body>
</html>

